/*
 * Copyright (c) 2006, 2021, webrx.cn All rights reserved.
 *
 */
package cn.webrx.example;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * <p>Project: javaseapp - Date01
 * <p>Powered by webrx On 2021-07-28 11:50:27
 * <p>Created by IntelliJ IDEA
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 16
 */
public class Date01 {
    public static void main(String[] args) {
        Date d = new Date();

        //时间戳 long 数字
        long t1 = d.getTime();
        long t2 = System.currentTimeMillis();

        //将long转成Date
        Date d3 = new Date(t2);

        Calendar c = Calendar.getInstance();

        c.set(2021, 5 - 1, 18);

        //将Calendar 日历类实例，转成Date
        Date d2 = c.getTime();
        SimpleDateFormat s = new SimpleDateFormat("yyyy年MM月dd日");
        System.out.println(s.format(d));
        System.out.println(s.format(d2));
    }
}
